Skip to content

Fixed: FileSystem.waitForFile: do not crash if directory does not exist yet#5421

Open
danielrentz wants to merge 1 commit intocodeceptjs:3.xfrom
danielrentz:issue5420
Open

Fixed: FileSystem.waitForFile: do not crash if directory does not exist yet#5421
danielrentz wants to merge 1 commit intocodeceptjs:3.xfrom
danielrentz:issue5420

Conversation

@danielrentz
Copy link
Contributor

Motivation/Description of the PR

Reworked the complex implementation of FileSystem.waitForFile, now it contains a simple polling loop that uses the existing fileExists helper function like FileSystem.seeFile does.

Applicable helpers:

  • Playwright
  • Puppeteer
  • WebDriver
  • REST
  • FileHelper
  • Appium
  • TestCafe

Applicable plugins:

  • allure
  • autoDelay
  • autoLogin
  • customLocator
  • pauseOnFail
  • coverage
  • retryFailedStep
  • screenshotOnFail
  • selenoid
  • stepByStepReport
  • stepTimeout
  • wdio
  • subtitles

Type of change

  • 🔥 Breaking changes
  • 🚀 New functionality
  • 🐛 Bug fix
  • 🧹 Chore
  • 📋 Documentation changes/updates
  • ♨️ Hot fix
  • 🔨 Markdown files fix - not related to source code
  • 💅 Polish code

Checklist:

  • Tests have been added
  • Documentation has been added (Run npm run docs)
  • Lint checking (Run npm run lint)
  • Local tests are passed (Run npm test)

throw new Error(`file (${name}) still not present in directory ${this.dir} after ${waitTimeout / 1000} sec`)
})
for (const t = Date.now() + sec * 1000; !fileExists(this.file); ) {
if (t < Date.now()) throw new Error(`file (${name}) still not present in directory ${this.dir} after ${sec} sec`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I don't understand how it works

But I agree current impleentation should be improved
Can we use while loop and some interval like 200ms to check this

And if it fails after sec seconds => throw error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

I.waitForFile (FileSystem helper) fails if directory does not exist (yet)

2 participants